import java.util.*;

/**
 * This program prints out the day of the week for a given
 * day (1..31), month (1..12) and year. 
 * @version 0.01 2014-01-16
 * @author Sergii Koziumynskyi
 */

public class CalendarSeeker
{
	public static void main(String[] args)
	{
	// preparations
		// ask user about date
		Scanner in = new Scanner(System.in);

		System.out.println("Enter a date in '10 October 2010' format.");
		String tmp = in.nextLine().trim();
		String[] arrTmp = tmp.split(" ");


		// check the input is valid and convert it
		boolean invalidInput = false;
		int day = 0;
		boolean invalidDay = false;
		int month = 0;
		boolean invalidMonth = false;
		int year = 0;
		boolean invalidYear = false;
		
		if (arrTmp.length != 3)
		{
			invalidInput = true;
		}
		else
		{
			// check Month
			if (arrTmp[1].equals("January")) month = 1;
			else if (arrTmp[1].equals("February")) month = 2;
			else if (arrTmp[1].equals("March")) month = 3;
			else if (arrTmp[1].equals("April")) month = 4;
			else if (arrTmp[1].equals("May")) month = 5;
			else if (arrTmp[1].equals("June")) month = 6;
			else if (arrTmp[1].equals("July")) month = 7;
			else if (arrTmp[1].equals("August")) month = 8;
			else if (arrTmp[1].equals("September")) month = 9;
			else if (arrTmp[1].equals("October")) month = 10;
			else if (arrTmp[1].equals("November")) month = 11;
			else if (arrTmp[1].equals("December")) month = 12;
			else 
			{
				invalidMonth = true;
				System.out.println("Entered '" + arrTmp[1] + "' is not valid value for a month.");
			}

			// check Year
			if (!invalidMonth)
			{
				try{
							year = Integer.parseInt(arrTmp[2]);
						} catch (NumberFormatException nfe) {
							System.out.println("Entered '" + arrTmp[0] + "' is not valid value for a year.");
							invalidYear = true;
						};
			}
					
			// check Day
			if (!invalidYear && !invalidMonth)
			{
				try{
						day = Integer.parseInt(arrTmp[0]);
					} catch (NumberFormatException nfe) {
						System.out.println("Entered '" + arrTmp[0] + "' is not valid value for a day.");
						invalidDay = true;
					};

				int maxDay = 0;
				switch (month)
				{
					case 1: case 3: case 5: case 7:
					case 8: case 10: case 12:
						maxDay = 31;
						break;
					case 4: case 6: case 9: case 11:
						maxDay = 30;
						break;
					case 2:
						if (year % 400 == 0) maxDay = 29;
						else if (year % 100 == 0) maxDay = 28;
						else if (year % 4 == 0) maxDay = 29;
						else maxDay = 28;
						break;
					default:
						System.out.println("Something really wrong happen :)");
						break;
				}
				
				if (day < 1 || day > maxDay ) {
					System.out.println("Entered day is not valid for the entered month.");
					invalidDay = true;
				}
			}
		}
		
	// main calculations
		if (invalidInput || invalidDay || invalidMonth || invalidYear)
		{
			System.out.println("Invalid Input. Execution is terminated.");
		}
		else
		{
			int a = (14 - month) / 12;
			int y = year - a;
			int m = month + 12 * a - 2;
			int dayOfWeek = (7000 + (day + y + y / 4 - y / 100 + y / 400 + (31 * m) / 12)) % 7;

			String [] output = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
			System.out.println(tmp + " is " + output[dayOfWeek]);
		}
	}
}